package StudyCode.summary.regularexpressionsmatch;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class SettingCaseSensitivityInARegularExpression {
	public static void main(String[] args) {
		CharSequence inputStr = "Abc";
		String patternStr = "abc";

		Pattern pattern = Pattern.compile(patternStr, Pattern.CASE_INSENSITIVE);
		Matcher matcher = pattern.matcher(inputStr);
		boolean matchFound = matcher.matches(); // true
		System.out.println("匹配结果:" + matchFound);
		matchFound = pattern.matches("abc", "aBc"); // false
		System.out.println("匹配结果:" + matchFound);
		matchFound = pattern.matches("(?i)abc", "aBc"); // true
		System.out.println("匹配结果:" + matchFound);
		matchFound = pattern.matches("a(?i)bc", "aBc"); // true
		System.out.println("匹配结果:" + matchFound);
		matchFound = pattern.matches("((?i)a)bc", "aBc"); // false
		System.out.println("匹配结果:" + matchFound);
		matchFound = pattern.matches("(?i:a)bc", "aBc"); // false
		System.out.println("匹配结果:" + matchFound);
		matchFound = pattern.matches("a((?i)b)c", "aBc"); // true
		System.out.println("匹配结果:" + matchFound);
		matchFound = pattern.matches("a(?i:b)c", "aBc"); // true
		System.out.println("匹配结果:" + matchFound);
		matchFound = pattern.matches("[a-c]+", "aBc"); // false
		System.out.println("匹配结果:" + matchFound);
		matchFound = pattern.matches("(?i)[a-c]+", "aBc"); // true
		System.out.println("匹配结果:" + matchFound);
	}
}
